package com.njust.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.njust.domain.dto.TrainPageQueryDTO;
import com.njust.domain.po.PersonnelCapabilitie;
import com.njust.domain.vo.TrainPageQueryProjectVO;
import com.njust.domain.vo.TrainPageQueryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @version 1.0
 * @Author Imak
 * @Date 2024/11/7 12:36
 * @人员能力表持久层
 */

public interface PersonnelCapabilitieMapper extends BaseMapper<PersonnelCapabilitie> {
    /**
     * 根据用户ID和项目ID查询人员能力记录
     * @param uId 用户ID
     * @param project_id 项目ID
     * @return 匹配的人员能力记录对象，如果未找到则返回null
     */
    PersonnelCapabilitie findByUserIdAndProjectId(@Param("uId") Integer uId, @Param("project_id") Integer project_id);

    Page<TrainPageQueryVO> personPageQuery(int project_id);
    void updatePersonnelCapabilitie(PersonnelCapabilitie personnelCapabilitie);

//
    @Select("select user.uName, product.category, project.project_name, product.product_name, project.standard_number,personnel_capabilitie.training_completion, training_cert_link ,assessment_completion, video_link, authorization_cert_link from personnel_capabilitie INNER JOIN user on personnel_capabilitie.uId = user.uId inner join project on project.project_id = personnel_capabilitie.project_id INNER JOIN product on project.product_id = product.product_id INNER JOIN video on personnel_capabilitie.video_id = video.video_id where personnel_capabilitie.project_id = #{project_id}")
    List<TrainPageQueryVO> selectAllPage(int project_id);
//    @Select("select user.uName, product.category, project.project_name, product.product_name, project.standard_number from personnel_capabilitie INNER JOIN user on personnel_capabilitie.uId = user.uId inner join project on project.project_id = personnel_capabilitie.project_id INNER JOIN product on project.product_id = product.product_id where personnel_capabilitie.project_id = #{project_id} and personnel_capabilitie.assessment_status = 2 limit #{trainPageQueryDTO.pageSize} offset #{trainPageQueryDTO.page};")
//    List<TrainPageQueryProjectVO> projectSelectPage(int project_id, TrainPageQueryDTO trainPageQueryDTO);

    Page<TrainPageQueryProjectVO> projectSelectPage(int project_id);

    @Select("select user.uName, product.category, project.project_name, product.product_name, project.standard_number from personnel_capabilitie INNER JOIN user on personnel_capabilitie.uId = user.uId inner join project on project.project_id = personnel_capabilitie.project_id INNER JOIN product on project.product_id = product.product_id where personnel_capabilitie.project_id = #{project_id} and personnel_capabilitie.assessment_status = 2")
    List<TrainPageQueryProjectVO> projectSelectAllPage(int project_id);
}
